package both.map.mapModel;

import java.awt.Dimension;
import org.w3c.dom.Document;

/**
 * The standard map model. Should be able to run on both server and client,
 * and be able to serve info to both MapView and to copies of itself.
 * 
 * @author jdl
 */
public class StandardMapModel implements MapCommunicator {
	private static final Dimension DEFAULT_CHUNK_SIZE = new Dimension(20,20); 
	private static final Dimension DEFAULT_CHUNK_GRID_SIZE = new Dimension(30,30);

	private ModelMap map;
	
	/**
	 * construct a new StandardMapModel, with a new map, given a chunk 
	 * size. Initially contains no actual chunks, these must be added 
	 * later.
	 * 
	 * @param chunkSize the Dimensions of each chunk
	 * @param chunkGridSize the Dimensions of the chunk grid
	 */
	public StandardMapModel(Dimension chunkSize, Dimension chunkGridSize)
	{
		map = new ModelMap(chunkSize, chunkGridSize);
	}
	
	/**
	 * construct a new StandardMapModel, with a pre-existing map.
	 * @param map the map to be placed in this model
	 */
	public StandardMapModel(ModelMap map)
	{
		this.map = map;
	}
	
	/**
	 * construct a new StandardMapModel, building a new map, using the 
	 * default chunk size. Initially contains no actual chunks, 
	 * these must be added later.
	 */
	public StandardMapModel()
	{
		this(DEFAULT_CHUNK_SIZE, DEFAULT_CHUNK_GRID_SIZE);
	}
	
	/**
	 * @return the entire map stored in this model
	 */
	public ModelMap getMap()
	{
		return map;
	}
	
	/**
	 * @return the chunk size of this model's map
	 */
	public Dimension getChunkSize()
	{
		return map.getChunksize();
	}
	
	/**
	 * generate a map containing elements to be updated. All others are
	 * null.
	 * @return the update map
	 */
	@Override
	public ModelMap generateUpdateMap()
	{
		return map.grabUpdate();
	}
	
	/** 
	 * generate an XML document representing the entire modelMap
	 */
	@Override
	public Document generateCompleteMapXML() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/**
	 * @see both.map.mapModel.MapCommunicator#updateWholeMap(org.w3c.dom.Document)
	 */
	@Override
	public void updateMap(Document newMap) {
		// TODO Auto-generated method stub

	}

}
